package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@TableName("t_refund_order_attachment")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.RefundOrderAttachmentMapper")
public class RefundOrderAttachmentDO extends BaseEntity {
    /**
     * 理赔主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long refundOrderId;

    /**
     * 序号
     */
    @TableId(type = IdType.ID_WORKER)
    private Integer no;

    /**
     * 文件类型
     */
    @TableField(value = "file_type")
    private String fileType;

    /**
     * 文件路径
     */
    @TableField(value = "file_path")
    private String filePath;

    /**
     * 文件名称
     */
    @TableField(value = "file_name")
    private String fileName;

    /**
     * 文件md5值
     */
    @TableField(value = "file_md5")
    private String fileMd5;

    /**
     * 下载文件url地址
     */
    @TableField(value = "file_url")
    private String fileUrl;

    /**
     * 文件理赔/赔付类型  1理赔  2赔付
     */
    @TableField(value = "business_type")
    private Integer businessType;
    /**
     * 创建时间
     */
    @TableField(value = "gmt_create")
    private Date gmtCreate;
    /**
     * 修改时间
     */
    @TableField(value = "gmt_modified")
    private Date gmtModified;

    public RefundOrderAttachmentVo buildVo() {
        return new RefundOrderAttachmentVo(refundOrderId, no, fileType, filePath, fileName, fileMd5, fileUrl, businessType, gmtCreate ,gmtModified);
    }

    public static RefundOrderAttachmentDO of(RefundOrderAttachmentVo vo) {
        return new RefundOrderAttachmentDO(vo.getRefundOrderId(), vo.getNo(), vo.getFileType(), vo.getFilePath(), vo.getFileName(), vo.getFileMd5(), vo.getFileUrl(), vo.getBusinessType(), vo.getGmtModified(), vo.getGmtModified());
    }
}
